use std::rc::Rc;

use crate::List::{Cons, Nil};

fn main() {
    let a = Rc::new(Cons(2, Rc::new(Cons(3, Rc::new(Nil)))));
    println!("{}", Rc::strong_count(&a));
    let _ = Cons(4, a.clone());
    println!("{}", Rc::strong_count(&a));
    {
        let b = Cons(5, a.clone());
        println!("{}", Rc::strong_count(&a));
        println!("{:?}", b);
    }
    println!("{}", Rc::strong_count(&a));
}

#[derive(Debug)]
enum List {
    Cons(i32, Rc<List>),
    Nil,
}
